<template>
	<view class="warp">
		<view  v-if="!auditShow">
			<other></other>
		</view>
		<!-- 背景图 -->
		<view class="bc_box">
			<view class="tetx">
				八字合婚
			</view>
		<view class="id_card_box" v-if="auditShow">
			<view class="boy_card">
				<view class="name">
					<view class="nameTable_item_left">男方姓名:</view>
					<input v-model="boyform.male_name" placeholder-class="placeholder-class" placeholder="请输入男方姓名" />
				</view>
				<view class="date_time" >
					<view class="nameTable_item_left">出生日期:</view>
					<!-- <view class="input">
						{{celenderValue}}
					</view> -->
					<input :disabled="true" v-model="celenderValue" @click="showCalendar=true" placeholder-class="placeholder-class" placeholder="请选择日期" />
						<e-run-calendar ref="betterCalendarRef" :showCalendar="showCalendar" @confirm="selectDate" :isHourShow="true"
						        @cancel="showCalendar = false" :selectOptions="selectOptionsArr"></e-run-calendar>
					<uni-icons style="margin-left: 20rpx;" @click="openlistfn(1)" type="list" size="16"></uni-icons>
				</view>
			</view>
			<view class="gir_card">
				<view class="name">
					<view class="nameTable_item_left">女方姓名:</view>
					<input v-model="boyform.female_name" placeholder-class="placeholder-class" placeholder="请输入女方姓名" />
				</view>
				<view class="date_time"   >
					<view class="nameTable_item_left">出生日期:</view>
					<!-- <view class="input">
						{{fecelenderValue}}
					</view> -->
					<input :disabled="true" v-model="fecelenderValue"   placeholder-class="placeholder-class" placeholder="请选择日期" />
						<e-run-calendar ref="betterCalendarRef" :showCalendar="feshowCalendar" @confirm="feselectDate" :isHourShow="true"
						        @cancel="feshowCalendar = false" :selectOptions="feselectOptionsArr"></e-run-calendar>
				<uni-icons style="margin-left: 20rpx;" @click="openlistfn(2)" type="list" size="16"></uni-icons>
				</view>
			</view>
		</view>
		
		<view class="nameTable_button"@click="syngfn">立即合婚</view>
		<uni-popup ref="popup" type="center" border-radius="30px 30px 30px 30px">
			<view class="list" style="width: 600rpx;height: 600rpx;">
				<view class="list_title">
					档案库
				</view>
				<view class="" style="overflow-y: scroll; max-height: 450rpx;">
					<view class="item" v-for="(item,index) in danganlist" :key="index">
						<view @click="selectfn(item)" class="item_c" style="display: flex;align-items: center;width: 100%;">
							<uni-icons color="#bb9435" type="circle" size="14"></uni-icons>
							<view class="" style="margin-left: 20rpx; ">
								<view class="name">
									{{item.masterName}}
								</view>
								<view class="date">
									{{item.masterBirthday}}
								</view>
							</view>
						</view>
						
					</view>
				</view>
				
			</view>
		</uni-popup>
	</view>
	</view>
</template>

<script>
	import eRunCalendar from "@/uni_modules/e-run-calendar/components/e-run-calendar/e-run-calendar.vue"
	import other from '@/components/other/index.vue'
	export default {
		components:{other,eRunCalendar},
		data() {
			return {
				auditShow:true,
				boyform:{
					api_key:"A4FpkA8Z2zMSZM7TjTE8sVoOV",
					masterInfoId:null,
					masterName:null,
					male_name:null,//男方姓名
					male_type:null,//0农历1公历
					male_year: null, 
					male_month:null, 
					male_day: null, 
					male_hours: null, 
					male_minute: null, 
					masterInfoGirlId:null,
					masterInfoGirlName:null,
					female_name:null,//女方姓名
					female_type:null,//0农历1公历
					female_year:null,
					female_month:null,
					female_day:null,
					female_hours:null,
					female_minute:null,
					payType:'BALANCE',
					payMethod:'balance',
					amount:0,//金额
					productId:5,
					productName:'八字合婚',
					productCover:null,
					productType:'4',
					productPrice:null,
				},
				
				showCalendar: false,//是否显示组件
				celenderValue: '',//选择值
				selectOptionsArr: [80, 0, 0, 0],///起始年份
				fecelenderValue:'',
				feshowCalendar: false,//是否显示组件
				feselectOptionsArr:[80, 0, 0, 0],///起始年份
				danganlist:[],//档案库数据
				openindex:null,
			};
		},
		onShow() {
			this.getAudit()
			
		},
		onLoad() {
			this.getreportlist()
		},
		methods:{
			// 获取推荐报告列表
			getreportlist(){
				this.$request({
					url:'v3/business/front/product/list',
					method:'GET',
					data:{
						productId:this.boyform.productId,
					},
				}).then(res=>{
					this.boyform.productId=res.data.list[0].productId
					this.boyform.productName=res.data.list[0].productName
					this.boyform.productType=res.data.list[0].productType
					this.boyform.salesCount=res.data.list[0].salesCount
					this.boyform.productDetail=res.data.list[0].productDetail
					this.boyform.productPrice=res.data.list[0].productPrice
					this.boyform.productCover=res.data.list[0].productCover
				})
				},
				// 选择信息
				openlistfn(val){
					this.openindex=val
					this.$refs.popup.open()
					this.getdanganlist()
				},
				// 获取档案数据
				getdanganlist(){
					 
					this.$request({
						url:'v3/member/front/master/list',
					}).then(res=>{
						if(res.state==200){
							this.danganlist=res.data
						}
					})
				},
				// 选择档案
				selectfn(val){
					this.$refs.popup.close()
					if(this.openindex==1){
						// 男方信息
						
						this.celenderValue=val.masterBirthday
						// this.boyform.isLeap=val.isLeap
						this.boyform.male_name=val.masterName
						this.boyform.male_year=val.masterBirthday.split(' ')[0].split('/')[0]
						this.boyform.male_month=val.masterBirthday.split(' ')[0].split('/')[1]
						this.boyform.male_day=val.masterBirthday.split(' ')[0].split('/')[2]
						this.boyform.male_hours=val.masterBirthday.split(' ')[1].split(':')[0]
						this.boyform.male_minute=val.masterBirthday.split(' ')[1].split(':')[1]
						this.boyform.male_type=val.isLeap=='true' || val.isLeap=="false"?'0':'1'
						this.boyform.masterInfoId=val.masterInfoId
						this.boyform.masterName=val.masterName
						
					}else if(this.openindex==2){
						this.fecelenderValue=val.masterBirthday
						// this.boyform.isLeap=val.isLeap
						this.boyform.female_name=val.masterName
						this.boyform.female_year=val.masterBirthday.split(' ')[0].split('/')[0]
						this.boyform.female_month=val.masterBirthday.split(' ')[0].split('/')[1]
						this.boyform.female_day=val.masterBirthday.split(' ')[0].split('/')[2]
						this.boyform.female_hours=val.masterBirthday.split(' ')[1].split(':')[0]
						this.boyform.female_minute=val.masterBirthday.split(' ')[1].split(':')[1]
						this.boyform.female_type=val.isLeap=='true' || val.isLeap=="false"?'0':'1'
						this.boyform.masterInfoGirlId=val.masterInfoId
						this.boyform.masterInfoGirlName=val.masterName
					}
					
					 console.log(this.boyform);
				},
				syngfn(){
					// 要传递的对象参数
					if(!this.boyform.male_name){
						this.$modal.msg('请输入男方姓名！')
						return false 
					}else if(!this.boyform.male_year){
						this.$modal.msg('请选择男方出生日期！')
						return false 
					}else if(!this.boyform.female_name){
						this.$modal.msg('请输入女方姓名！')
						return false
					}else if(!this.boyform.female_year){
						this.$modal.msg('请选择男方出生日期！')
					}
					uni.navigateTo({
						url:"/pages/moreModule/ordertest/ordertest?syngobj="+encodeURIComponent(JSON.stringify(this.boyform))
					})
				},
			//获取微信审核开关
			getAudit(){
			    let param = {};
				param.url='v3/system/front/configuration/1'
				this.$request(param).then(res=>{
					this.auditShow=res.data.auditSwitch
					if(this.auditShow){
						uni.setNavigationBarTitle({
							title:'八字合婚'
						})
					}
					
				})
			},
			selectDate(e){
				if(e.type == 'solar'){
					//公历
					// this.currentIndex=0
					// this.boyform.isLeap=null
					this.boyform.male_type=1
					this.boyform.male_year=e.year
					this.boyform.male_month=e.month
					this.boyform.male_day=e.day
					this.boyform.male_hours=(e.hour+1).toString().padStart(2, '0')
					this.boyform.male_minute="00"
					this.celenderValue=e.year+'/'+e.month+'/'+e.day+'/'+' '+(e.hour+1).toString().padStart(2, '0')+":"+'00'
				}else if(e.type == 'lunar'){
					//农历
					// this.currentIndex=1
					this.celenderValue=e.year+'/'+e.month+'/'+e.day+'/'+' '+(e.hour+1).toString().padStart(2, '0')+":"+'00'
					//判断是否闰月
					this.boyform.male_type=0
					this.boyform.male_year=e.year
					this.boyform.male_month=e.month
					this.boyform.male_day=e.day
					this.boyform.male_hours=(e.hour+1).toString().padStart(2, '0')
					this.boyform.male_minute="00"
					// this.boyform.isLeap= e.leap_month == 1 ? 'true':'false'
				
				}
				// console.log('this.form.masterBirthday',this.boyform.masterBirthday);
				this.showCalendar=false
			},
			feselectDate(e){
				 
				if(e.type == 'solar'){
					//公历
					// this.currentIndex=0
					// this.boyform.isLeap=null
					this.boyform.female_type=1
					this.boyform.female_year=e.year
					this.boyform.female_month=e.month
					this.boyform.female_day=e.day
					this.boyform.female_hours=(e.hour+1).toString().padStart(2, '0')
					this.boyform.female_minute="00"
					this.fecelenderValue=e.year+'/'+e.month+'/'+e.day+'/'+' '+(e.hour+1).toString().padStart(2, '0')+":"+'00'
				}else if(e.type == 'lunar'){
					//农历
					// this.currentIndex=1
					this.fecelenderValue=e.year+'/'+e.month+'/'+e.day+'/'+' '+(e.hour+1).toString().padStart(2, '0')+":"+'00'
					//判断是否闰月
					this.boyform.female_type=0
					this.boyform.female_year=e.year
					this.boyform.female_month=e.month
					this.boyform.female_day=e.day
					this.boyform.female_hours=(e.hour+1).toString().padStart(2, '0')
					this.boyform.female_minute="00"
					// this.boyform.isLeap= e.leap_month == 1 ? 'true':'false'
				
				}
				// console.log('this.form.masterBirthday',this.boyform.masterBirthday);
				this.feshowCalendar=false
			},
			natTo(url,item){
				// 要传递的对象参数
				if(!this.boyform.male_name){
					this.$modal.msg('请输入男方姓名！')
					return false 
				}else if(!this.boyform.male_year){
					this.$modal.msg('请选择男方出生日期！')
					return false 
				}else if(!this.boyform.female_name){
					this.$modal.msg('请输入女方姓名！')
					return false
				}else if(!this.boyform.female_year){
					this.$modal.msg('请选择男方出生日期！')
				}
				const obj = this.boyform
				
				// 将对象参数转为JSON字符串，并使用encodeURIComponent编码
				const params = encodeURIComponent(JSON.stringify(obj));
				
				// 跳转页面并传递对象参数
				uni.navigateTo({
				   url: `${url}?params=${params}`
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
page{
	// padding: 16rpx;
	background-color: #fff;
}
// 弹出狂样式
	.list{
		padding: 28rpx;
		border-radius: 20rpx;
		// text-align: center;
		background-color: #fff;
		.list_title{
			font-size: 30rpx;
			font-weight: 550;
			color: #88b7ff;
			margin-bottom: 20rpx;
			padding-bottom: 10rpx;
			border-bottom: 2rpx solid #cecece;
			text-align: center;
		}
		.item{
			padding: 10rpx 20rpx;
			font-size: 26rpx;
			border-bottom: 2rpx solid #cecece;
			display: flex;
			align-items: center;
			.name{
				font-size: 28;
				padding: 10rpx 0;
				font-weight: 550;
			}
			.date{
				color: #cecece;
			}
		}
		
	}
.warp{
	// padding: 50rpx 40rpx;
	font-size: 28rpx;
	.bc_box{
          background-color: #fcb4d9;
		  height: 500rpx;
		  padding: 40rpx 30rpx;
		  position: relative;
		  .tetx{
			  padding-top: 60rpx;
			  font-size: 80rpx;
			  font-weight: 550;
			  width: 100%;
			  text-align: center;
			  color: #f9fefc;
		  }
	.id_card_box{
	      position: absolute;
	      top: 320rpx;
	      left: 50rpx;
		  right: 50rpx;
	      background-color: #fff;
	      border-radius: 20rpx;
	      padding:30rpx;
	      box-shadow: 2px 2px 5px #cecece;
	.gir_card,.boy_card{
		.name{
			display: flex;
			align-items: center;
			margin-bottom: 18rpx;
		.nameTable_item_left{
				margin-right: 20rpx;
			}
		}
		
		.date_time{
			display: flex;
			align-items: center;
			.nameTable_item_left{
				margin-right: 20rpx;
			}
		}
	}
	.boy_card{
		padding-bottom: 20rpx;
		border-bottom: 2rpx solid #cecece;
	}
	.gir_card{
		padding-top: 20rpx;
	}
	}
	.nameTable_button{
		color: #f9fefc;
		margin-top: 48rpx;
		border-radius: 15rpx;
		font-size: 40rpx;
		padding: 24rpx 240rpx;
		text-align: center;
		background-color: #fcb4d9;
		position: absolute;
		top: 682rpx;
		left: 50rpx;
		right: 50rpx;
		box-shadow: 2px 2px 5px #cecece;
	}    
	}
}
</style>
